# Maintainer: Dan McGee <dan@archlinux.org>

pkgname=pgbouncer
pkgver=1.7.2
pkgrel=3
pkgdesc="A lightweight connection pooler for PostgreSQL"
arch=('i686' 'x86_64')
url="https://wiki.postgresql.org/wiki/PgBouncer"
license=('BSD')
depends=('libevent>=2.0' 'c-ares' 'systemd')
makedepends=('asciidoc' 'xmlto')
backup=('etc/pgbouncer/pgbouncer.ini' 'etc/logrotate.d/pgbouncer')
install=$pkgname.install
source=("https://pgbouncer.github.io/downloads/files/$pkgver/$pkgname-$pkgver.tar.gz"
        pgbouncer.ini
        pgbouncer.logrotate
        pgbouncer.service
        pgbouncer.tmpfiles.conf
        usual-openssl.patch)
sha256sums=('de36b318fe4a2f20a5f60d1c5ea62c1ca331f6813d2c484866ecb59265a160ba'
            '4f30e4a3eb76acdd233ebc7dd099dff6976299ba958e40a8429b74112e804b05'
            '8da38746d9c9dfc2433a8cfe22fdaf517e14492672d09e3c48cd4745fc03e9bd'
            '274a3d447c151323f2d297aae881ec69be1477f16e30b0bba469afe68c2d122a'
            '476ea0400ba063e932a58f1f49ae401d65b22add521894872c09ec6985e0960d'
            '46d2d1c421ccd9893af4f6fde28d796b7910d2385efd3e27cca118d8e484ca7b')

prepare() {
  cd "$srcdir/$pkgname-$pkgver/lib"
  patch -Np1 -i ../../usual-openssl.patch
}

build() {
  cd "$srcdir/$pkgname-$pkgver"
  ./configure --prefix=/usr --disable-debug
  make
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  make DESTDIR="$pkgdir/" install
  install -D -m644 COPYRIGHT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -D -m644 ../pgbouncer.ini "$pkgdir/etc/pgbouncer/pgbouncer.ini"
  install -D -m644 ../pgbouncer.logrotate "$pkgdir/etc/logrotate.d/pgbouncer"
  install -D -m644 ../pgbouncer.service "$pkgdir/usr/lib/systemd/system/pgbouncer.service"
  install -D -m644 ../pgbouncer.tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/pgbouncer.conf"
  mkdir -p "$pkgdir/var/log/pgbouncer"
}

# vim:set ts=2 sw=2 et:
